﻿using System;
#if WPF
using System.Windows.Shapes;
#else
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Shapes;
using Windows.UI.Xaml.Data;
#endif

namespace Eternal.DataVisualization
{
    public class HiLoSeries : StockType
    {
        protected internal override void ApplyBrush(Shape element, int index)
        {
            element.StrokeThickness = StrokeThickness;
            element.Stroke = SegmentBrush ?? Area.GetBrush(index);
        }

        protected internal override void OnDrawSegment()
        {
            base.OnDrawSegment();
            if (XAxis != null && YAxis != null)
            {
                SegmentPanel.Children.Clear();
                double dataCount = ActualXData.Count;

                for (var i = (int)Math.Floor(XAxis.Start); i <= (int)Math.Ceiling(XAxis.End); i++)
                {
                    var verLine = new Line();

                    SegmentPanel.Children.Add(verLine);

                    ApplyBrush(verLine, i);

                    verLine.X1 = ValueToCoordianteXAxis(i);
                    verLine.Y1 = ValueToCoordianteYAxis( ActualLow[i]);
                    verLine.X2 = ValueToCoordianteXAxis(i);
                    verLine.Y2 = ValueToCoordianteYAxis(ActualHigh[i]);
                }
            }
        }

    }
}
